{extend name="base"/}
{block name="resources"}
{/block}
{block name="main"}
<div class="layui-collapse ns-tips">
	<div class="layui-colla-item">
		<h2 class="layui-colla-title">操作提示</h2>
		<ul class="layui-colla-content layui-show">
			<li>发票设置</li>
		</ul>
	</div>
</div>

<div class="layui-form ns-form">
	<div class="layui-form-item">
		<label class="layui-form-label"><span class="required">*</span>发票开关：</label>
		<div class="layui-input-inline">
			<input type="radio" name="status" value="0" title="关闭" autocomplete="off" class="layui-input ns-len-long" {if $invoice_config.status == 0} checked {/if}>
			<input type="radio" name="status" value="1" title="开启" autocomplete="off" class="layui-input ns-len-long" {if $invoice_config.status == 1} checked {/if}>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label"><span class="required">*</span>发票税率：</label>
		<div class="layui-input-block">
			<input type="number" name="rate" min="0" lay-verify="required" value="{$invoice_config.rate}" placeholder="请输入税率"  autocomplete="off" class="layui-input ns-len-short">
		</div>
	</div>
	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label"><span class="required">*</span>发票内容</label>
		<div class="layui-input-block ns-len-long">
			<textarea name="content" placeholder="请输入内容" lay-verify="required" class="layui-textarea">{$invoice_config.content}</textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label"><span class="required">*</span>邮寄费用：</label>
		<div class="layui-input-block">
			<input type="number" name="money" value="{$invoice_config.money}" min="0" lay-verify="required" value="" placeholder="请输入费用" autocomplete="off" class="layui-input ns-len-short">
		</div>
	</div>

	<div class="ns-form-row">
		<button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
	</div>
</div>
{/block}
{block name="script"}
<script>
	layui.use(['form'], function() {
		var form = layui.form,
			repeat_flag = false; //防重复标识
		form.render();

		form.on('submit(save)', function(data) {

			if (repeat_flag) return;
			repeat_flag = true;

			$.ajax({
				type: 'POST',
				dataType: 'JSON',
				url: ns.url("admin/config/invoice"),
				data: data.field,
				success: function(res) {
					layer.msg(res.message);
					if (res.code == 0) {
						location.reload();
					}else{
						repeat_flag = false;
					}
				}
			});
		});

	});
</script>
{/block}